package com.maxd.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * 学员信息
 */
@Entity
@Getter
@Setter
@ToString
@SuperBuilder
@ApiModel("学员信息")
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "student_info")
public class StudentInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @ApiModelProperty("自增主键")
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty("关联用户ID")
    @Column(name = "user_id", nullable = false)
    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @Column(name = "user_phone")
    @ApiModelProperty("关联用户登录手机号")
    private String userPhone;

    @ApiModelProperty("学员姓名")
    @Column(name = "name", nullable = false)
    @NotBlank(message = "姓名不能为空")
    private String name;

    @ApiModelProperty("性别 M-男 F-女")
    @Column(name = "sex", nullable = false)
    @NotBlank(message = "性别不能为空")
    @Pattern(regexp = "M|F", message = "性别输入不正确")
    private String sex;

    @ApiModelProperty("生日，格式为yyyy-MM-dd")
    @Column(name = "birthday")
    private String birthday;

    @ApiModelProperty("兴趣爱好")
    @Column(name = "interest")
    private String interest;

    @ApiModelProperty("备注")
    @Column(name = "remark")
    private String remark;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time", nullable = false)
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time", nullable = false)
    private Date updateTime;

    @ApiModelProperty("创建人")
    @Column(name = "create_by")
    private String createBy;

    @ApiModelProperty("更新人")
    @Column(name = "update_by")
    private String updateBy;

}
